import java.util.Comparator;
/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 张宇田
 * Date: 2025-03-24
 * Time: 13:49
 */
public class Drink {
    String name;
    int price;
    int volume;
    double unitPrice;

    public Drink(String name,int price,int volume){
        this.name = name;
        this.price = price;
        this.volume = volume;
        this.unitPrice = (double) price / volume;
    }

    @Override
    public String toString() {
        /*
        return "Drink{" +
                "name='" + name + '\'' +
                '}';*/
        return  name +" ";
    }
}
//按照价格降序排序 o2在o1前
//此处不能强转类型，会导致精度丢失，例如 0.11就会丢失        return (int)(o2.unitPrice - o1.unitPrice);
class DrinkComparator implements Comparator<Drink>{
    public int compare(Drink o1,Drink o2){
        return Double.compare(o2.unitPrice,o1.unitPrice);
    }
}